{% extends 'GlpmrUserBundle::layout.html.twig' %}

{% block body %}
    <div class="row">
        <h1>Liste des utilisateurs</h1>
    </div>
    <br />
    <div class="row">
        <div class="col s12">
            <table class="striped bordered tableSorter" id="list">
                <thead class="blue-grey darken-4">
                    <tr>
                        <th data-field="username" rowspan="2">Username</th>
                        <th data-field="email" rowspan="2">E-mail</th>
                        <th data-field="promotion" rowspan="2">Promotion</th>
                        <th data-field="action" colspan="2">Actions</th>
                    </tr>
                    <tr>
                        <th data-field="edit">Edit</th>
                        <th data-field="delete">Delete</th>
                    </tr>
                </thead>
                <tbody>
                    {% for user in users %}
                        <tr class="userList {{ user.username|first|upper }} {{ user.promotion.libelle }}">
                            <td>&nbsp;&nbsp;{{ user.username }}</td>
                            <td>{{ user.email }}</td>
                            <td>{{ user.promotion.libelle }}</td>
                            <td class="center">
                                <a href="{{ path('glpmr_user_modifier', {'id': user.id} ) }}">
                                    <button class="margin1 btn btn-floating waves-effect waves-light teal"><i class="mdi-content-create"></i></button>
                                </a>
                            </td>
                            <td class="center">
                                <a href="#confirmSuppr" class="modal-trigger" id="{{ user.id }}" data-type="user">
                                    <button class="margin1 btn btn-floating waves-effect waves-light red darken-1"><i class="mdi-content-clear"></i></button>
                                </a>
                            </td>
                        </tr>
                    {% endfor %} 
                </tbody>
            </table>
        </div>
    </div>

    <!-- Modal(Dialog) Structure -->
    <div id="confirmSuppr" class="modal">
        <h4>Confirmer</h4>
        <p>
            &Ecirc;tes-vous s&ucirc;r de vouloir supprimer ce compte ?
        </p>
        <a href="" class="suppr waves-effect btn-flat green">oui!</a>
        <a href="#" class="waves-effect btn-flat red modal-close">Non</a>
    </div>
{% endblock %}

